package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Region;
import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.IStrategyCatalogService;
import cn.wolfcode.wolf2w.util.JsonResult;
import cn.wolfcode.wolf2w.util.UMEditorUploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;


    @GetMapping("/hotRegion")
    public Object hotRegion() {
        List<Region> regions = regionService.getHotRegion();
        return JsonResult.success(regions);
    }

    @GetMapping("/search")
    public Object search(String regionId) {
        List<Destination> destinations = destinationService.getDestByRegionIdForApi(regionId);
        return JsonResult.success(destinations);
    }

    @GetMapping("/getToastsByDestId")
    public Object getToastsByDestId(String destId) {
        List<Destination> dests = destinationService.queryToast(destId);
        return JsonResult.success(dests);
    }

    @GetMapping("/getCatalogsByDestId")
    public Object getCatalogsByDestId(String destId) {
        List<StrategyCatalog> strategyCatalogs = strategyCatalogService.query(destId);
        return JsonResult.success(strategyCatalogs);
    }


    @GetMapping("/list")
    public Object list() {
        return JsonResult.success(destinationService.list());
    }


}
